<%--
  Created by IntelliJ IDEA.
  User: ZZDZZ
  Date: 2024/6/20
  Time: 9:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
<head>
    <title>图书列表</title>
    <style>
        table, th, td {
            border: 1px solid black;
            border-collapse: collapse;
        }
        th, td {
            padding: 5px;
            text-align: left;
        }
    </style>
</head>
<body>
<h1 align="center">图书列表</h1>
<table align="center">
    <tr>
        <th>用户ID</th>
        <th>用户名</th>
        <th>身份</th>
        <th>状态</th>
        <th>违规次数</th>
    </tr>
    <c:forEach items="${usersList}" var="user">
        <tr>
            <td>${user.userId}</td>
            <td>${user.userName}</td>
            <td>${user.isAdmin == 1 ? '管理员' : '普通用户'}</td>
            <td>${user.status == 1 ? '正常' : '禁用'}</td>
            <!-- 根据book.isAdmin,status的值显示不同的链接 -->
            <td>${user.violationCount}</td>
            <td>
                <c:choose>
                    <c:when test="${user.status == 0}">
                        <!-- 用户被禁用，显示解禁链接 -->
                <a href="unlockUser?userId=${user.userId}">解禁</a>
                    </c:when>
                    <c:otherwise>
                        <!-- 用户正常，不显示解禁链接 -->
                        用户正常
                    </c:otherwise>
                </c:choose>
            </td>
            <td><a href="upUser?userId=${user.userId}">升级为管理员</a></td>
            <td><a href="deleteUser?userId=${user.userId}">删除用户</a></td>
        </tr>
    </c:forEach>
</table>
</body>
</html>
